<?php
/**
 * 
 * @author yuxun
 *
 */

class BossFallController extends AdminBaseController {
	
	public function index(){
		$filter = new PubFilter();
		$grid = new PubGrid();
	
		$header = BossFallService::indexHeader();
	
		$lod_special_id = $this->R('special_id');
		$lodos = $this->R('os');
		$filter->addSpecialFilter(false,2);
		$filter->addOsFilter($lod_special_id,true,2);
		$filter->addServerFilter($lod_special_id,$lodos,true,false,2)
		->addFilter('time_start', 'input', PubFunc::t('时间'), array('date' => 'day', 'value' => date('Y-m-d', strtotime('-1 day'))),2)
		->addFilter('time_end', 'input', PubFunc::t('至'), array('date' => 'day', 'value' => date('Y-m-d', strtotime('-1 day'))),2)		
		->addExport();
		
		$filter->addFilter('BossId', 'input', 'BossId');
		$filter->addFilter('ItemId', 'input', '物品ID');
		
		$this->setTitle('BOSS掉落物品统计');
		$params = $filter->get();		
		$params = $this->indexCommon($params);
	
		if($filter->isExport()){
			ini_set('memory_limit','1024M');
			$result = BossFallService::indexData($params);
			LibExcel::exportCsv($header, $result['data'], "Mango数据后台-boss掉落({$params['time_start']}).csv");
			exit();
		}else if(PubFunc::isAjax()){
			$result = BossFallService::indexData($params);
			$this->out = array(
					'count'     => $result['count'],
					'data'      => $result['data'],
					'result'    => true
			);
			$this->outType = 'json';

		}else{
			$order  = 'BossId';
			$url = PubFunc::ajaxUrl("?r=bossFall/index", $params);
			$grid->addGrid($header, $url, array(
					'name'=>'数据',
					'order'=>array($order, 'desc'),
					'type'=>'bossFall/index',
					'length'=>50,
					'page'=>$page,
					'fix'   => array(
							'col' => 6
					)
			));
	
			$this->out['grid'] = $grid->show();
			$this->out['filter'] = $filter->show();
	
			$this->out['is_ana'] = 2;
		}
	}
	
	
	public function starIndex(){
		$filter = new PubFilter();
		$grid = new PubGrid();

	
		$lod_special_id = $this->R('special_id');
		$lodos = $this->R('os');
		$filter->addSpecialFilter(false,2);
		$filter->addOsFilter($lod_special_id,true,2);
		$filter->addServerFilter($lod_special_id,$lodos,true,false,2)
		->addFilter('time_start', 'input', PubFunc::t('时间'), array('date' => 'day', 'value' => date('Y-m-d', strtotime('-1 day'))),2)
		->addFilter('time_end', 'input', PubFunc::t('至'), array('date' => 'day', 'value' => date('Y-m-d', strtotime('-1 day'))),2)
		->addExport();
	
		$filter->addFilter('BossId', 'input', 'BossId');
	
		$this->setTitle('BOSS掉落品质装备统计');
		$params = $filter->get();
		$params = $this->indexCommon($params);
		$header = BossFallService::starHeader($params);
		if($filter->isExport()){
			ini_set('memory_limit','1024M');
			$result = BossFallService::starData($params);
			LibExcel::exportCsv($header, $result, "Mango数据后台-boss掉落品质装备({$params['time_start']}).csv");
			exit();
		}else{
			$result = BossFallService::starData($params);
			$order  = 'BossId';	
			$grid->addGrid($header, $result, array(
					'name'=>'数据',
					'order'=>array($order, 'desc'),
					'type'=>'bossFall/starIndex',
					'length'=>50,
					'page'=>$page,
					'fix'   => array(
							'col' => 6
					)
			));
	
			$this->out['grid'] = $grid->show();
			$this->out['filter'] = $filter->show();
	
			$this->out['is_ana'] = 2;
		}
	}
	
    

    


} 
